package com.appspot.gaeforum309.pathing;

import java.util.List;

import com.appspot.gaeforum309.core.ForumAPI;
import com.appspot.gaeforum309.db.DBCategory;
import com.appspot.gaeforum309.pathing.Action.ActionType;
import com.appspot.gaeforum309.pathing.PathBuilder.IPathable;

public class PathRoot implements IPathable {
	public static final String tagName = "Root";
	public static final String tagKey = "RootKey";
	
	private static final PathRoot instance = new PathRoot();
	
	public static final PathableClass pathable = new PathableClass(tagName, null){

		@Override
		public IPathable getObject(String keyStr) {
			if(tagKey.equals(keyStr))
				return instance;
			return null;
		}
	};
	
	@Override
	public String getKeyStr() {
		return tagKey;
	}

	@Override
	public String getParentKeyStr() {
		return null;
	}

	@Override
	public PathableClass getPathable() {
		return pathable;
	}

	@Override
	public String label() {
		return ForumAPI.Config.getForumName();
	}

	@Override
	public List<? extends IPathable> getChilds(int fromNumber, int toNumber) {
		return getChilds().subList(fromNumber, toNumber);
	}

	@Override
	public List<? extends IPathable> getChilds() {
		return DBCategory.getAllCategories();
	}
	
	@Override
	public boolean authorizedAction(ActionType actionType) {
		switch(actionType)
		{
		default:
			return false;
		}
	}
	
	@Override
	public boolean applyAction(Action action) {
		switch(action.getActionType())
		{
		case createChild:
			
			break;	
		}
		return false;
	}
}
